package com.yic.module.base.api.workshop;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.yic.module.base.api.workshop.dto.WorkshopRespDTO;
import com.yic.module.base.convert.workshop.WorkshopConvert;
import com.yic.module.base.dal.dataobject.workshop.WorkshopDO;
import com.yic.module.base.service.workshop.WorkshopService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.Set;

/**
 * @Author: Ljx
 * @createTime: 2023年11月29日 10:31:02
 * @version: v1.0.0
 * @Description: 生产车间API实现
 */
@Service
public class WorkshopApiImpl implements WorkshopApi{

    @Resource
    private WorkshopService workshopService;
    @Override
    public WorkshopRespDTO getWorkshop(Long id) {
        if (ObjectUtil.isNull(id)){
            return null;
        }
        WorkshopDO workshop = workshopService.getWorkshop(id);
        return WorkshopConvert.INSTANCE.convert01(workshop);
    }

    @Override
    public List<WorkshopRespDTO> getWorkshopList(Set<Long> workshopIds) {
        if (CollectionUtil.isEmpty(workshopIds)) {
            return Collections.emptyList();
        }
        List<WorkshopDO> workshopList = workshopService.getWorkshopList(workshopIds);
        return WorkshopConvert.INSTANCE.convertList04(workshopList);
    }
}
